package net.neptech.controller;
import net.neptech.entity.vo.dto.CreateConferenceDTO;
import net.neptech.entity.vo.ConferenceVO;
import net.neptech.entity.vo.ParticipantVO;
import net.neptech.service.ConferenceService;
import net.neptech.vm.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ConferenceController")
public class ConferenceController {

    @Autowired
    private ConferenceService conferenceService;

    // 创建会议
    @PostMapping("/createConference")
    public ResponseResult<String> createConference(@RequestBody CreateConferenceDTO dto) {
        String conferenceId = conferenceService.create(dto.getUserId(), dto.getUserName());
        return ResponseResult.success(conferenceId); // 返回会议ID
    }

    // 获取会议信息--也就是根据会议id查询会议是否存在
    @GetMapping("/{conferenceId}")
    public ResponseResult<ConferenceVO> getConference(@RequestParam String conferenceId) {
        ConferenceVO vo = conferenceService.getByConferenceId(conferenceId);
        return ResponseResult.success(vo);
    }

    // 医生加入会议，根据会议的id和医生信息进入会议
    @PostMapping("/{conferenceId}/join")
//    @SaCheckLogin 这里需要进行权限校验，需要分析这个医生能不能加入这个会议
    public ResponseResult<ConferenceVO> joinConference(
            @PathVariable String conferenceId,
            @RequestBody ParticipantVO participantVO) { // Sa-Token 提供的注解，但是这里我先修改为加入会议的医生

        ConferenceVO result = conferenceService.join(conferenceId, participantVO);
        return ResponseResult.success(result);
    }

}